package ensib.sti.ssu.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseInterface extends SQLiteOpenHelper {
	private static final String TABLE_BLOC_NOTE = "blocnote";
	private static final String COL_ID = "id";
	private static final String COL_DESCRIPTION = "description";
	private static final String COL_DEADLINE = "deadlinedate";
	private static final String COL_PRIORITE = "priorite";
	private static final String COL_NOM_TACHE = "nomtache";
	private static final String COL_TYPE_TACHE = "typetache";
	private static final String COL_PHOTO_URL = "photourl";
	
	private static final String CREATE_BDD = "CREATE TABLE " + TABLE_BLOC_NOTE+ " ("
	+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DESCRIPTION+ " TEXT NOT NULL, "
	+ COL_PRIORITE + " int NOT NULL default  1 , "+ COL_DEADLINE+" TEXT, "+COL_NOM_TACHE+"  TEXT NOT NULL , "+COL_TYPE_TACHE+" int NOT NULL default 1 , "+COL_PHOTO_URL+" TEXT default NULL);";
 
	public DataBaseInterface(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(CREATE_BDD);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE " + TABLE_BLOC_NOTE + ";");
		onCreate(db);
	}

}
